﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using TestGlobal.ServiceReference1;
using NATP2P.STUN;
using System.Net;
namespace TestGlobal
{
    public partial class Form1 : Form
    {
        PeersWebService1SoapClient soap = new PeersWebService1SoapClient();
        public Form1()
        {
            InitializeComponent();
        }
        EndPointMapRequest req;
        private void Form1_Load(object sender, EventArgs e)
        {
           
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
           
            req = new EndPointMapRequest(2012, "stun.stunprotocol.org");
            req.Send();
            ExchangPacket peer = new ExchangPacket();
            peer.User = Dns.GetHostName();
            peer.PublicAddress = req.ExternalEndPoint.Address.ToString();
            peer.PublicPort = req.ExternalEndPoint.Port.ToString();
            soap.AddPeer(peer);
            listBox1.Items.Clear();
            foreach (var item in soap.GetPeers())
            {
                listBox1.Items.Add(item.User);
            }
           
        }
    }
}
